package com.weiyi.weiman.utils;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * @Author zhang
 * @Date 2021/5/2 下午9:50
 * @Description 实现加密和解密，采用md5+盐的方式
 * @Version 1.0
 **/
public class CryptographyUtils {

    private static final String salt = "zxsqert!@";

    private static final int insertIndex = 4;

    public static String encryption(String msg) {
        //在指定位置插入盐
        StringBuilder newMsg = new StringBuilder(msg);
        newMsg.insert(insertIndex, salt);

        return DigestUtils.md5Hex(newMsg.toString());
    }

}
